﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace BOHVote.DAL
{
    public class ReportProvide
    {
        Database db;
        public ReportProvide()
        {
            db = DatabaseFactory.CreateDatabase();
        }

        public DataSet ReportSubjectSApply(string strApplyPeriod, string subjectID,string IsPassed)
        {
            string strSP = "SP_AllApplyReport";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);
            db.AddInParameter(dbcommand, "@SubjectID", DbType.String, subjectID);
            db.AddInParameter(dbcommand, "@IsPassed", DbType.String, IsPassed);
            return db.ExecuteDataSet(dbcommand);
        }

        public DataSet ReportSubjectHeightApply(string strApplyPeriod, string subjectID, string IsPassed)
        {
            string strSP = "SP_AllHApplyReport";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);
            db.AddInParameter(dbcommand, "@SubjectID", DbType.String, subjectID);
            db.AddInParameter(dbcommand, "@IsPassed", DbType.String, IsPassed);
            return db.ExecuteDataSet(dbcommand);
        }

        public DataSet ReportUnitApply(string strApplyPeriod, string GovernID)
        {
            string strSP = "sp_ReportUnit";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);
            db.AddInParameter(dbcommand, "@GovernID", DbType.String, GovernID);

            return db.ExecuteDataSet(dbcommand);
        }

        public DataSet ReportGovernApply(string strApplyPeriod)
        {
            string strSP = "sp_ReportGovern";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);
            return db.ExecuteDataSet(dbcommand);
        }

        public DataSet ReportUnitHeightApply(string strApplyPeriod, string GovernID)
        {
            string strSP = "sp_UnitHeightReport";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);
            db.AddInParameter(dbcommand, "@GovernID", DbType.String, GovernID);

            return db.ExecuteDataSet(dbcommand);
        }

        public DataSet ReportGovernHeightApply(string strApplyPeriod)
        {
            string strSP = "sp_GovernHeightReport";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);

            return db.ExecuteDataSet(dbcommand);
        }

        public DataSet ReportSubjectApply(string strApplyPeriod, string strAccreditationLevel)
        {
            string strSP = "sp_SubjectReport";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);
            db.AddInParameter(dbcommand, "@AccreditationLevel", DbType.String, strAccreditationLevel);

            return db.ExecuteDataSet(dbcommand);
        }

        public DataSet ReportSubjectHeightApply(string strApplyPeriod, string strAccreditationLevel)
        {
            string strSP = "sp_SubjectHeightReport";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);
            db.AddInParameter(dbcommand, "@AccreditationLevel", DbType.String, strAccreditationLevel);

            return db.ExecuteDataSet(dbcommand);
        }

        public DataSet ReportSubjectApplyInfo(string subjectID,string strApplyPeriod)
        {
            string strSP = "sp_SubjectApplyInfo";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);
            db.AddInParameter(dbcommand, "@SubjectID", DbType.String, subjectID);

            return db.ExecuteDataSet(dbcommand);
        }

        public DataSet ReportSubjectApplyInfoBlank(string subjectID, string strApplyPeriod)
        {
            string strSP = "sp_SubjectApplyInfoBlank";
            DbCommand dbcommand = db.GetStoredProcCommand(strSP);
            db.AddInParameter(dbcommand, "@ApplyPeriodID", DbType.String, strApplyPeriod);
            db.AddInParameter(dbcommand, "@SubjectID", DbType.String, subjectID);

            return db.ExecuteDataSet(dbcommand);
        }
    }
}
